package com.zkthink.ceres.finance.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zkthink.base.R;
import com.zkthink.base.request.PageParams;
import com.zkthink.ceres.finance.dto.MemberCashOutAuditDTO;
import com.zkthink.ceres.finance.dto.MemberCashOutAuditPageDTO;
import com.zkthink.ceres.finance.dto.MemberCashOutDetailPageDTO;
import com.zkthink.ceres.finance.dto.MemberCashOutDetailSaveDTO;
import com.zkthink.ceres.finance.service.MemberCashOutDetailService;
import com.zkthink.ceres.finance.vo.MemberCashOutDetailVO;
import com.zkthink.log.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * 提现明细表
 * </p>
 *
 * @author vivi.huang
 * @date 2020-05-25
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/memberCashOutDetail")
@Api(value = "MemberCashOutDetail", tags = "会员提现明细表")
//@PreAuth(replace = "cashOutDetail:")
@AllArgsConstructor
public class MemberCashOutDetailController {
    @Autowired
    private MemberCashOutDetailService memberCashOutDetailService;

    /**
     * 提现
     */
    @ApiOperation(value = "提现")
    @PostMapping
    public R<Boolean> doCashOut(@RequestBody MemberCashOutDetailSaveDTO collectingAccountSaveDTO) {
        return memberCashOutDetailService.doMemberCashOut(collectingAccountSaveDTO);
    }


    /**
     * 提现明细分页
     */
    @ApiOperation(value = "提现明细分页查询")
    @PostMapping("/page")
    @SysLog(value = "提现明细分页查询", request = false)
    public R<IPage<MemberCashOutDetailVO>> findCashOutDetailPage(@RequestBody PageParams<MemberCashOutDetailPageDTO> pageParams) {
        return memberCashOutDetailService.findMemberCashOutDetailPage(pageParams);
    }

    /**
     * 提现明细分页
     */
    @ApiOperation(value = "提现明细审核分页")
    @PostMapping("/page/audit")
    @SysLog(value = "提现审核分页查询", request = false)
    public R<IPage<MemberCashOutAuditDTO>> findAuditCashOutDetailPage(@RequestBody PageParams<MemberCashOutAuditPageDTO> pageParams) {
        return memberCashOutDetailService.findAuditMemberCashOutDetailPage(pageParams);
    }

    /**
     * 提现审核
     */
    @ApiOperation(value = "提现审核")
    @PostMapping("/audit")
    @SysLog(value = "提现审核", request = false)
    public R<Boolean> auditCashOut(@RequestBody MemberCashOutAuditDTO cashOutAuditDTO) {
        return memberCashOutDetailService.auditMemberCashOut(cashOutAuditDTO);
    }

    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "主键", dataType = "long", paramType = "query"),})
    @ApiOperation(value = "查询提现审核", notes = "查询提现审核")
    @GetMapping("/audit/{id}")
    @SysLog("'查询提现审核:' + #id")
    public R<MemberCashOutAuditDTO> getCashOutAudit(@PathVariable Long id) {
        return memberCashOutDetailService.getMemberCashOutAudit(id);
    }

}
